import { createRouter, createWebHistory } from "vue-router";
const routes = [{
        path: "/",
        redirect: "/home",
    },
    {
        path: "/home",
        name: "Home",
        component: () =>
            import ("../views/Home.vue"),
        children: [{
                path: "/home",
                redirect: "/home/index",
            },
            {
                path: "/home/index",
                name: "index",
                component: () =>
                    import ("../views/home/index.vue"),
            },
            {
                path: "/home/classify",
                name: "classify",
                component: () =>
                    import ("../views/home/classify.vue"),

            },

            {
                path: "/home/shop",
                name: "shop",
                component: () =>
                    import ("../views/home/shop.vue"),
            },
            {
                path: "/home/me",
                name: "me",
                component: () =>
                    import ("../views/home/me.vue"),
                meta: {
                    loginmes: false,
                }
            },
        ],
    },

    // {
    //     path: "/home",
    //     name: "Home",
    //     component: () =>
    //         import ("../views/Home.vue"),
    // },
    {
        path: "/login",
        name: "login",
        component: () =>
            import ("../views/login.vue"),
    },
    {
        path: "/changeinfor",
        name: "changeinfor",
        component: () =>
            import ("../views/changeinfo.vue"),
    },
    {
        path: "/userinfo",
        name: "userinfo",
        component: () =>
            import ("../views/userInfo.vue"),
    },
    {
        path: "/imgurl",
        name: "/imgurl",
        component: () =>
            import ("../views/imgurl.vue"),
    },
    {
        path: "/userAddress",
        name: "/userAddress",
        component: () =>
            import ("../views/userAddress.vue"),
    },
    {
        path: "/addAdd",
        name: "/addAdd",
        component: () =>
            import ("../views/addAdd.vue"),
    },
    {
        path: "/404",
        name: "404",
        component: () =>
            import ("../views/404.vue"),
    },
    {
        path: "/home/details",
        name: "detail",
        component: () => {
            return import ("../views/details.vue")
        }
    },


    {
        path: "/detail/:id",
        component: () =>
            import ("../views/Detail.vue"),
        props: true //这里就把id传到对应的detail里了
    },
    {
        path: "/:pathMatch(.*)",
        redirect: "404",
    },
    // 详情页router


];

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
});

export default router;